@extends('admin.layout')
@section('title','订单列表')
@section('body')
    <div class="container1">
        <div id="search" style="height:63px;">
            {{--<blockquote class="layui-elem-quote" style="font-size: 14px">--}}
                {{--<form action="{{url('http://egui.gebixianxiang.com:8081/BGoods/Data/bySn')}}" method="post" class="layui-form">--}}
                    {{--<div class="layui-form-item">--}}
                        {{--<div  class="layui-inline">--}}
                            {{--<label class="layui-form-label">搜索</label>--}}
                            {{--<div class="layui-input-inline">--}}
                                {{--<input type="tel" id="Sn" name="Sn"  lay-verify="required" placeholder="请输入订单号" autocomplete="off" class="layui-input ">--}}
                            {{--</div>--}}
                        {{--</div>--}}

                        {{--<div class="layui-inline">--}}
                            {{--<input  type="button"  onclick="sear()" class="layui-btn layui-btn-small" value="搜索">--}}
                        {{--</div>--}}
                        {{--<div class="layui-inline">--}}
                            {{--商品销售额@{{count.total}}元,成交订单@{{count.num}}笔.--}}
                        {{--</div>--}}
                    {{--</div>--}}
                {{--</form>--}}
            {{--</blockquote>--}}
        {{--</div>--}}
        <div id="search" style="height:63px;">
            <blockquote class="layui-elem-quote" style="font-size: 14px">
                <form action="" method="post" class="layui-form">
                    <div class="layui-form-item">
                        <div  class="layui-inline">
                            <label class="layui-form-label">经销商</label>
                            <div class="layui-input-inline">
                                <select name="admin_id" lay-filter="admin" lay-verify="" lay-search>
                                    <option value="0">选择</option>
                                    @foreach($admin as $value)
                                        <option value="{{$value->admin_id}}">{{$value->username}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div  class="layui-inline">
                            <label class="layui-form-label">按店铺</label>
                            <div class="layui-input-inline">
                                <select name="shop_id" lay-filter="shop" lay-verify="" lay-search>
                                    <option value="0">选择</option>
                                    @foreach($shop as $value)
                                        <option value="{{$value->id}}">{{$value->grogsgopname}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div  class="layui-inline">
                            <label class="layui-form-label">按分类</label>
                            <div class="layui-input-inline">
                                <select name="class_id" lay-filter="class" lay-verify="" lay-search>
                                    <option value="0">选择</option>
                                    @foreach($class as $value)
                                        <option value="{{$value->id}}">{{$value->name}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                    </div>
                    <input type="reset" id="reset" value="" style="display:none;">
                </form>
            </blockquote>
        </div>
        <table class="layui-table " >
            <colgroup>

            </colgroup>
            <thead>
            <tr>
                <th>分销商</th>
                <th>店铺名</th>
                <th>商品名</th>
                <th>价格</th>
                <th>状态</th>
                <th>图片</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr v-for="value in lists">
                <td>@{{value.adminname}}</td>
                <td>@{{value.shopname}}</td>
                <td>@{{value.goodsname}}</td>
                <td>@{{value.price}}</td>
                <td>@{{value.status | val }}</td>
                <td><img style="width: 100px;" :src="value.image" alt=""></td>
                <td>

                    <input type="button" class="btn btn-danger" @click="goods_down( value.goodsid )" value="下架">
                    <input type="button" class="btn btn-info" @click="goods_edit( value.goodsid )" value="改价">
                </td>
            </tr>
            </tbody>
        </table>
        <div id="page"></div>
        <div id="page1"></div>
        <div id="page2"></div>
        <div id="page3"></div>
        <div id="dialog" style="display: none">
            <table class="table table-bordered table-responsive">
                <tr>
                    <td>分销商</td>
                    <td>@{{goodsdetail.adminname}}</td>
                    <td>店铺</td>
                    <td>@{{goodsdetail.shopname}}</td>
                </tr>
                <tr>
                    <td>柜机</td>
                    <td>@{{goodsdetail.chesname}}</td>
                    <td>商品</td>
                    <td>@{{goodsdetail.goodsname}}</td>
                </tr>
                <tr>
                    <td>价格</td><td>@{{goodsdetail.price}}</td>
                    <td>时间</td><td>@{{goodsdetail.time}}</td>
                </tr>
                <tr>
                    <td  colspan="2">图片</td>
                    <td colspan="2"><img :src="goodsdetail.image" style="width: 200px;" alt=""></td>
                </tr>
            </table>
        </div>
    </div>
@endsection
@section('js')
    <script src="{{asset('js/vue.min.js')}}"></script>
    <script>
        @if(Session::has('message'))
             layer.msg("{{Session::get("message")}}");
                {{Session::forget('message')}}
                @endif

        var vm=new Vue({
                el:".container1",
                data:{
                    lists:"",
                    count:"",
                    goodsdetail:""

                },
                mounted:function () {
                    layui.use(['laypage', 'layer','form'], function() {
                        var laypage = layui.laypage,layer = layui.layer,form = layui.form();
                        $("#page").show();
                        $("#page1").hide();
                        $("#page2").hide();
                        $("#page3").hide();
                        laypage({
                            cont: 'page'
                            ,pages:'{{$pages}}'
                            ,skin: '#1E9FFF'
                            ,skip:true
                            ,jump:function (obj,first) {
                                if(first){
                                    $.get({
                                        url:'http://egui.gebixianxiang.com:8081/BGoods/Data/BgoodsbyAll',
                                        data:{'pages':1},
                                        success:function (res) {
                                            vm.lists=res.BGoods;
                                            obj.pages=Math.ceil((res.num)/15);
                                        }
                                    })
                                }else{
                                    $.get({
                                        url:'http://egui.gebixianxiang.com:8081/BGoods/Data/BgoodsbyAll',
                                        data:{'pages':obj.curr},
                                        success:function (res) {
                                            vm.lists=res.BGoods;
                                        }
                                    })
                                }
                            }
                        });
                        form.on('select(admin)', function(data){
                          $("#reset").click();
                            if(data.value==0){
                                $.get({
                                    url:'http://egui.gebixianxiang.com:8081/BGoods/Data/BgoodsbyAll',
                                    data:{'pages':1},
                                    success:function (res) {
                                        vm.lists=res.BGoods;
                                        obj.pages=Math.ceil((res.num)/15);
                                    }
                                })
                            }else{
                                $.get({
                                    url:'{{url('http://egui.gebixianxiang.com:8081/BGoods/Data/BgoodsbyAadmin')}}',
                                    data:{'pages':1,'adminid':data.value},
                                    success:function (res) {
                                        vm.lists=res.BGoods;
                                        $("#page").hide();
                                        $("#page1").show();
                                        $("#page2").hide();
                                        $("#page3").hide();
                                        laypage({
                                            cont: 'page1'
                                            ,pages:2
                                            ,skin: '#1E9FFF'
                                            ,skip:true
                                            ,jump:function (obj,first) {
                                                if(first){
                                                    $.get({
                                                        url:'http://egui.gebixianxiang.com:8081/BGoods/Data/BgoodsbyAadmin',
                                                        data:{'pages':1,'adminid':data.value},
                                                        success:function (res) {
                                                            vm.lists=res.BGoods;
                                                            obj.pages=Math.ceil((res.num)/15);
                                                        }
                                                    })
                                                }else{
                                                    $.get({
                                                        url:'http://egui.gebixianxiang.com:8081/BGoods/Data/BgoodsbyAadmin',
                                                        data:{'pages':obj.curr,'adminid':data.value},
                                                        success:function (res) {
                                                            vm.lists=res.BGoods;
                                                        }
                                                    })
                                                }
                                            }
                                        });
                                    }
                                })

                            }
                        });

                        form.on('select(shop)', function(data){
                            $("#reset").click();
                            if(data.value==0){
                                $.get({
                                    url:'http://egui.gebixianxiang.com:8081/BGoods/Data/BgoodsbyAll',
                                    data:{'pages':1},
                                    success:function (res) {
                                        vm.lists=res.BGoods;
                                        obj.pages=Math.ceil((res.num)/15);
                                    }
                                })
                            }else{
                                $.get({
                                    url:'{{url('http://egui.gebixianxiang.com:8081/BGoods/Data//BgoodsbyShop')}}',
                                    data:{'pages':1,'shopid':data.value},
                                    success:function (res) {
                                        vm.lists=res.BGoods;
                                        $("#page").hide();
                                        $("#page1").hide();
                                        $("#page2").show();
                                        $("#page3").hide();
                                        laypage({
                                            cont: 'page2'
                                            ,pages:2
                                            ,skin: '#1E9FFF'
                                            ,skip:true
                                            ,jump:function (obj,first) {
                                                if(first){
                                                    $.get({
                                                        url:'http://egui.gebixianxiang.com:8081/BGoods/Data//BgoodsbyShop',
                                                        data:{'pages':1,'shopid':data.value},
                                                        success:function (res) {
                                                            vm.lists=res.BGoods;
                                                            obj.pages=Math.ceil((res.num)/15);
                                                        }
                                                    })
                                                }else{
                                                    $.get({
                                                        url:'http://egui.gebixianxiang.com:8081/BGoods/Data//BgoodsbyShop',
                                                        data:{'pages':obj.curr,'shopid':data.value},
                                                        success:function (res) {
                                                            vm.lists=res.BGoods;
                                                        }
                                                    })
                                                }
                                            }
                                        });
                                    }
                                })
                            }
                        });


                        form.on('select(class)', function(data){
                            $("#reset").click();
                            if(data.value==0){
                                $.get({
                                    url:'http://egui.gebixianxiang.com:8081/BGoods/Data/BgoodsbyAll',
                                    data:{'pages':1},
                                    success:function (res) {
                                        vm.lists=res.BGoods;
                                        obj.pages=Math.ceil((res.num)/15);
                                    }
                                })
                            }else{
                                $.get({
                                    url:'{{url('http://egui.gebixianxiang.com:8081/BGoods/Data/Bgoodsbyclass')}}',
                                    data:{'pages':1,'classid':data.value},
                                    success:function (res) {
                                        vm.lists=res.BGoods;
                                        $("#page").hide();
                                        $("#page1").hide();
                                        $("#page2").hide();
                                        $("#page3").show();
                                        laypage({
                                            cont: 'page3'
                                            ,pages:2
                                            ,skin: '#1E9FFF'
                                            ,skip:true
                                            ,jump:function (obj,first) {
                                                if(first){
                                                    $.get({
                                                        url:'http://egui.gebixianxiang.com:8081/BGoods/Data/Bgoodsbyclass',
                                                        data:{'pages':1,'classid':data.value},
                                                        success:function (res) {
                                                            vm.lists=res.BGoods;
                                                            obj.pages=Math.ceil((res.num)/15);
                                                        }
                                                    })
                                                }else{
                                                    $.get({
                                                        url:'http://egui.gebixianxiang.com:8081/BGoods/Data/Bgoodsbyclass',
                                                        data:{'pages':obj.curr,'classid':data.value},
                                                        success:function (res) {
                                                            vm.lists=res.BGoods;
                                                        }
                                                    })
                                                }
                                            }
                                        });
                                    }
                                })
                            }
                        });


                    });
                },
                    filters:{
                        val :function (val) {
                            if(val==0){
                                return val='已上架';
                            }
                            if(val==3){
                                return val='已下架'
                            }
                        }
                    }

            });



        function goods_down(id) {
            layer.open({
                title:"提示？",
                content:'确定修改？<form id="goods_down" method="post" ><input type="hidden" name="goods_id" value="'+id+'">{{csrf_field()}}</form>',
                yes:function () {
                    $("#goods_down").submit();
                }
            });
        }

        function goods_edit(id) {
            layer.open({
                title:"修改价格为",
                content:'<form id="goods_edit" method="post" ><input type="hidden" name="goods_id" value="'+id+'"><input type="text" name="price" class="form-control" >{{csrf_field()}}</form>',
                yes:function () {
                    $("#goods_edit").submit();
                }
            });
        }

    </script>

@endsection
